package emulator.hardware.bits;

public class SharedCollectorBit extends SharedBit {
	BitCollector collector;
	int index;
	
	public SharedCollectorBit (BitCollector collector, int index)
	{
		this.collector = collector;
		this.index = index;
	}

	/* (non-Javadoc)
	 * @see emulator.util.SharedBit#getValue()
	 */
	@Override
	public synchronized boolean getValue() {
		return super.getValue();
	}

	/* (non-Javadoc)
	 * @see emulator.util.SharedBit#setValue(boolean)
	 */
	@Override
	public synchronized void setValue(boolean value) {
		super.setValue(value);
		collector.setBit(index, value);
	}

	/* (non-Javadoc)
	 * @see emulator.util.SharedBit#toggle()
	 */
	@Override
	public synchronized void toggle() {
		super.toggle();
		collector.setBit(index, getValue());
	}
}
